﻿using Rud.Holmgren.TabulexLib;
using Rud.Holmgren.TabulexLib.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Rud.Holmgren.Tabulex3000.CommunicationTasks
{
    class GetChildInfoTask : TbxTask
    {
        private TbxChild child;

        public GetChildInfoTask(TbxClient client, TbxChild child)
            : base(client, "Henter aftaler for " + child.firstname)
        {
            this.child = child;
        }

        public override IPromise<bool> Run()
        {
            var retval = new Deferred<bool>();

            client.GetChildInfo(child).Done(cinfo =>
            {
                UpdateModel(cinfo);
                retval.Resolve(true);
            }).Fail(retval.Reject);

            return retval;
        }

        private void UpdateModel(TbxChildInfo cinfo)
        {

        }
    }
}
